package com.lambda.skin;

import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;

import com.iyoyi.skinlib.SkinManager;
import com.lambda.skin.base.BaseActivity;

import java.io.FileNotFoundException;

public class SettingActivity extends BaseActivity {

    @Override
    protected int getLayoutId() {
        return R.layout.activity_setting;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);

        findViewById(R.id.base).setOnClickListener(mListener);
        findViewById(R.id.skin1).setOnClickListener(mListener);
    }

    private final View.OnClickListener mListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.base:
                    SkinManager.restore();
                    break;

                case R.id.skin1:
                    try {
                        SkinManager.load("skin1.apk");
                    } catch (PackageManager.NameNotFoundException | FileNotFoundException e) {
                        e.printStackTrace();
                    }
                    break;
            }
        }
    };
}
